﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Wordpress.Phone.ViewModels;
using Microsoft.SilverlightMediaFramework.Core.Media;
using Microsoft.SilverlightMediaFramework.Utilities.Extensions;

namespace Wordpress.Phone
{
    public partial class MoviePage : PhoneApplicationPage
    {
        protected MovieViewModel viewModel;
        
        public MoviePage()
        {
            InitializeComponent();
            this.viewModel = new MovieViewModel();
            DataContext = this.viewModel;
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            string selectedIndex = "";
            if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex))
            {
                int index = int.Parse(selectedIndex);
                this.viewModel.LoadMovie(index);
            }
        }
    }
}